<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>编辑文章</title>
    <meta charset="UTF-8">
    <style>
        .container {
            max-width: 600px;
            margin: auto;
            padding: 20px;
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-group label {
            display: block;
            font-weight: bold;
        }

        .form-group input[type="text"],
        .form-group textarea {
            width: 100%;
            padding: 10px;
            font-size: 16px;
            border-radius: 4px;
            border: 1px solid #ccc;
        }

        .form-group .visibility-label {
            font-weight: normal;
        }

        .form-group {
            margin-left: 10px;
            margin-top: 10px;
        }

        .form-group button {
            padding: 10px 20px;
            font-size: 16px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }

        .errorMsg {
            width: 250px;
            height: 40px;
            background-color: #e4b9c0;
            margin-top: -60px;
            margin-left: 220px;
            text-align: center;
            line-height: 40px;
            border-radius: 5px;
        }

    </style>
    <style>
        .button-link {
            display: inline-block;
            padding: 10px 20px;
            background-color: #337ab7;
            color: #fff;
            font-size: 16px;
            text-decoration: none;
            border-radius: 4px;
        }
    </style>

    <script>
        function handleVisibilityChange(checkbox) {
            var checkboxes = document.getElementsByName('visibility');
            checkboxes.forEach(function (item) {
                if (item !== checkbox) {
                    item.checked = false;
                }
            });
        }

    </script>
</head>
<body>
<div class="container">
    <h1 style="margin-left: 10px">编辑文章</h1>
    <div class="errorMsg" style="font-size: 25px">${errorMsg}</div>
    <form action="user/updateArticle?rid=${article.rid}" method="post">
        <div class="form-group">
            <label for="title">标题:</label>
            <input type="text" id="title" name="title" value="${article.title}" required>
        </div>
        <div class="form-group">
            <label for="content">内容:</label>
            <textarea id="content" name="text" rows="8" required>${article.text}</textarea>
        </div>
        <div class="form-group">
            <label>可见性:</label>
            <div class="btn-group" role="group" aria-label="可见性选项">
                <label class="visibility-label">
                    <input type="checkbox" id="public" name="visibility" value="Y" checked
                           onclick="handleVisibilityChange(this)">
                    公开
                </label>
                <label class="visibility-label">
                    <input type="checkbox" id="private" name="visibility" value="N"
                           onclick="handleVisibilityChange(this)">
                    仅自己可见
                </label>
            </div>
        </div>
        <div class="form-group">
            <button type="submit">保存</button>
            <a href="${pageContext.request.contextPath}/person.html" class="button-link">返回</a>

        </div>
    </form>
</div>

</body>
</html>
